#include <stdio.h>
#include <stdlib.h>

int fun ( int a, int n ) {
    int i, j, sum = 0, add;
    char str[1000] = {0};
    for ( i = 0; i < n; i++ ) {
        str[i] = a + '0';
    }
    for ( j = n; j >= 0; j-- ) {
        str[j] = 0;
        add = atoi(str);
        sum+=add;
    }
    return sum;
}

int main () {
    int a = 2, n = 3, sum;
    sum = fun(a,n);
    return 0;
}